#pragma once
class CHasPtr {
private:
	int val;
	int*ptr;
public:
	CHasPtr(const int &p, int i) :ptr(new int(p)), val(i) {}
	CHasPtr(const CHasPtr &rchp) {
		val = rchp.val;
		ptr = new int(*rchp.ptr);
	}
	CHasPtr operator=(CHasPtr *rchp);
	int *get_ptr()const { return ptr; }
	int get_int()const { return val; }
	void set_ptr(int *p) { ptr = p; }
	void set_val(int i) { val = i; }
	int get_ptr_val() const { return *ptr; }
	void set_ptr_val(int val) { ptr = new int(val); }
};
CHasPtr CHasPtr::operator=(CHasPtr *rchp) {
	val = rchp->val;
	ptr = new int(*rchp->ptr); 
	return *this;
}